<h3>{$Think.lang.talk_detail}</h3>
<dl>
    <dt>{$Think.lang.talk_list}{$Think.lang.ds_colon}</dt>
    <dd>
        <div id="div_talk" class="div_talk"> </div>
    </dd>
</dl>
{if $complain_info.complain_state !== '99'}
<dl>
    <dt>{$Think.lang.talk_send}{$Think.lang.ds_colon}</dt>
    <dd>
        <textarea id="complain_talk" class="w400"></textarea>
    </dd>
</dl>
<div class="bottom clearfix">
    <a id="btn_publish" class="submit pl15 pr15 fl ml100">{$Think.lang.talk_send}</a> 
    <a id="btn_refresh" class="submit pl15 pr15 fl ml15">{$Think.lang.talk_refresh}</a> 
    <a id="btn_handle" class="submit pl15 pr15 fl ml15">{$Think.lang.handle_submit}</a> 
</div>
{/if}
<form action="{:url('Sellercomplain/apply_handle')}" method="post" id="handle_form">
    <input name="input_complain_id" type="hidden" value="{$complain_info.complain_id}" />
</form>
<script type="text/javascript">
    $(document).ready(function(){
        get_complain_talk();
        $("#btn_publish").click(function(){
            if($("#complain_talk").val()=='') {
                layer.msg("{$Think.lang.talk_null}");
            }
            else {
                publish_complain_talk();
            }
        });
        $("#btn_refresh").click(function(){
            get_complain_talk();
        });
        $("#btn_handle").click(function(){
            layer.confirm("{$Think.lang.handle_confirm_message}", {
                btn: ['{$Think.lang.ds_ok}', '{$Think.lang.ds_cancel}'],
                title: false,
            }, function () {
                $("#handle_form").submit();
            });
        });
    });
    function get_complain_talk() {
        $("#div_talk").empty();
        $.ajax({
            type:'POST',
            url:"{:url('Sellercomplain/get_complain_talk')}",
            cache:false,
            data:"complain_id={$complain_info.complain_id}",
            dataType:'json',
            error:function(){
                $("#div_talk").append("<p class='admin'>"+"{$Think.lang.talk_none}"+"</p>");
            },
            success:function(talk_list){
                if(talk_list.length >= 1) {
                    for(var i = 0; i < talk_list.length; i++)
                    {
                        $("#div_talk").append("<p class='"+talk_list[i].css+"'>"+talk_list[i].talk+"</p>");
                    }
                }
                else {
                    $("#div_talk").append("<p class='admin'>"+"{$Think.lang.talk_none}"+"</p>");
                }
            }
        });
    }
    function publish_complain_talk() {
        $.ajax({
            type:'POST',
            url:"{:url('Sellercomplain/publish_complain_talk')}",
            cache:false,
            data:"complain_id={$complain_info.complain_id}&complain_talk="+encodeURIComponent($("#complain_talk").val()),
            dataType:'json',
            error:function(){
                layer.msg("{$Think.lang.talk_send_fail}");
            },
            success:function(talk_list){
                if(talk_list == 'success') {
                    $("#complain_talk").val('');
                    get_complain_talk();
                    layer.msg("{$Think.lang.talk_send_success}");
                }
                else {
                    layer.msg("{$Think.lang.talk_send_fail}");
                }
            }
        });
    }
</script>